144

Beginner’s Guide to Code Algorithms

144

11.1  FEATURES OF THE GRAPH

Let’s begin with the chart and then look at the other different features that are put

together around it. Best done through an example, here is what we want.

A graph of number of COVID cases by US state (once you see the technique, you

can easily extend it to other geographic regions around the world). We want it by day

because that shows a clear trend (upward or downward). We want to see cumulative

up to each date, as well as new cases separately because each means slightly different

things in the trend chart. While most rely on this metric to determine how safe a place is,

the other metric is number of deaths due to COVID. Deaths typically lag the infection

by several weeks to several months, hence may not be the best indicator of safety, but

certainly an indicator of other things such as the state’s ability to handle cases, quality of

care, and so on. It would be great to see comparisons of different states. Also, we would

like to see the top N states so that that gives us a sense for the worst affected states.

We must remember that numbers are not everything—​there are many factors in­

volved in judging safety, and this analysis is just an experiment to help you develop

charts. However, charts and graphs have a pretty loudmouth and tell a story that is

worth a thousand words.

11.2  THE DATA

Before we begin, we have to get the data. Luckily, COVID data are publicly available

from multiple sources and are updated on a daily basis. The source I have chosen

for this exercise is https://​usa​fact​ssta​tic.blob.core.wind​ows.net/​pub​lic/​data/​covid-​19.

There are two files that are available in this web address:

• covid_​confirmed_​usafacts.csv

• covid_​deaths_​usafacts.csv

The names are self-​explanatory.

Both these files have the same format as shown below, each cell showing the

number of new cases in the days specified in the column header.

FIGURE 11.6  covid_​confirmed_​usafacts.csv.